CC=gcc
NASM=nasm
EXECUTABLE=libfiber.so

all: $(EXECUTABLE)

$(EXECUTABLE): fibthread.o fibthread_asm.o mutex.o sched.o attr.o fibsignal.o debug.o
	gcc -shared -Wall -m32 -o libfiber.so fibthread_asm.o fibthread.o mutex.o sched.o attr.o fibsignal.o debug.o  

fibthread.o: fibthread.c  fibthread.h  fibthreadtypes.h attr.h list.h sched.h asm.h debug.h
	$(CC) -fPIC -g -DDEBUG -DDEBUG_LEVEL=1 -Wall -c -m32 -o fibthread.o fibthread.c

mutex.o: mutex.c  list.h  sched.h fibthread.h 
	$(CC) -fPIC -g -Wall -c -m32 -o mutex.o mutex.c

sched.o: sched.c  list.h  sched.h asm.h
	$(CC) -fPIC -g -DDEBUG -DDEBUG_LEVEL=1 -Wall -c -m32 -o sched.o sched.c

attr.o: attr.c  fibthread.h 
	$(CC) -fPIC -g -Wall -c -m32 -o attr.o attr.c

fibsignal.o: fibsignal.c  fibsignal.h 
	$(CC) -fPIC -g -Wall -c -m32 -o fibsignal.o fibsignal.c

debug.o: debug.c  debug.h
	$(CC) -fPIC -g -Wall -c -m32 -o debug.o debug.c

fibthread_asm.o: fibthread_asm.asm
	$(NASM) -f elf -g -F stabs fibthread_asm.asm 

clean:
	rm *.o
	rm $(EXECUTABLE)

